import os
import tornado
import tornado.options
from tornado.web import RequestHandler, StaticFileHandler

class IndexHandler(RequestHandler):
    def get(self):
        house_info = {
            "price": 398,
            "title": "宽窄巷子+160平大空间+文化保护区双地铁",
            "score": 5,
            "comments": 6,
            "position": "北京市丰台区六里桥地铁"
        }
        self.render("index.html", **house_info)

class IndexHandler01(RequestHandler):
    def get(self):
        house_info = {
            "p1": 198,
            "p2": 200,
            "titles": ["宽窄巷子", "160平大空间", "文化保护区双地铁"],
            "score": 5,
            "comments": 6,
            "position": "北京市丰台区六里桥地铁"
        }
        self.render("index2.html", **house_info)


current_path = os.path.dirname(os.path.dirname(__file__))
app = tornado.web.Application(
    [
        (r'^/$', IndexHandler),
        (r'^/html$', IndexHandler01),
        (r'^/view/(.*)$', StaticFileHandler, {"path":os.path.join(current_path, "statics/html")}),
    ],
    static_path=os.path.join(current_path, "statics"),
    template_path=os.path.join(os.path.dirname(os.path.dirname(__file__)), "templates"),
)

if __name__ == "__main__":
    tornado.options.parse_command_line()
    app.listen(8888)
    tornado.ioloop.IOLoop.current().start()

